
package org.efficientsoap.test.deserializer;

import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.efficientsoap.client.EfficientSoapDeserializer;
import org.efficientsoap.client.EfficientSoapFaultException;

import android.util.Log;

import org.efficientsoap.test.results.*;
import org.efficientsoap.test.datatypes.*;
/**
 * Java (Android) version of a parsing helper class for the output parameter encapsulating Return Types
 * using the EfficientSoap.org SOAP client library project.
 *
 * @author Christian Rau
 */
public class MethodReturnTypesDeserializer{

private static final String TAG = MethodReturnTypesDeserializer.class.getSimpleName();
	public static DoubleInBooleanListOutReturn parseDoubleInBooleanListOutReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseDoubleInBooleanListOutReturn()");

		DoubleInBooleanListOutReturn doubleInBooleanListOutReturn = new DoubleInBooleanListOutReturn();
		Boolean isbooleanListReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("booleanListReturn") && isbooleanListReturnUnReaded){

 				doubleInBooleanListOutReturn.setBooleanListReturn(DataTypeDeserializer.parseBooleanList(eSoapDeserializer, "booleanListReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<booleanListReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "DoubleInBooleanListOutReturn");
		eSoapDeserializer.getParser().nextToken();
		return doubleInBooleanListOutReturn;
	}

	public static GenerateComplexDataReturn parseGenerateComplexDataReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseGenerateComplexDataReturn()");

		GenerateComplexDataReturn generateComplexDataReturn = new GenerateComplexDataReturn();
		Boolean iscomplexReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("complexReturn") && iscomplexReturnUnReaded){

 				generateComplexDataReturn.setComplexReturn(DataTypeDeserializer.parseComplexData(eSoapDeserializer, "complexReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<complexReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "GenerateComplexDataReturn");
		eSoapDeserializer.getParser().nextToken();
		return generateComplexDataReturn;
	}

	public static GeneratePrimitiveDataReturn parseGeneratePrimitiveDataReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseGeneratePrimitiveDataReturn()");

		GeneratePrimitiveDataReturn generatePrimitiveDataReturn = new GeneratePrimitiveDataReturn();
		Boolean isprimitiveReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("primitiveReturn") && isprimitiveReturnUnReaded){

 				generatePrimitiveDataReturn.setPrimitiveReturn(DataTypeDeserializer.parsePrimitiveData(eSoapDeserializer, "primitiveReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<primitiveReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "GeneratePrimitiveDataReturn");
		eSoapDeserializer.getParser().nextToken();
		return generatePrimitiveDataReturn;
	}

	public static GenerateRecursiveDataReturn parseGenerateRecursiveDataReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseGenerateRecursiveDataReturn()");

		GenerateRecursiveDataReturn generateRecursiveDataReturn = new GenerateRecursiveDataReturn();
		Boolean isrecursiveReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("recursiveReturn") && isrecursiveReturnUnReaded){

 				generateRecursiveDataReturn.setRecursiveReturn(DataTypeDeserializer.parseRecursiveData(eSoapDeserializer, "recursiveReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<recursiveReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "GenerateRecursiveDataReturn");
		eSoapDeserializer.getParser().nextToken();
		return generateRecursiveDataReturn;
	}

	public static GenerateSimpleDataReturn parseGenerateSimpleDataReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseGenerateSimpleDataReturn()");

		GenerateSimpleDataReturn generateSimpleDataReturn = new GenerateSimpleDataReturn();
		Boolean issimpleReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("simpleReturn") && issimpleReturnUnReaded){

 				generateSimpleDataReturn.setSimpleReturn(DataTypeDeserializer.parseSimpleData(eSoapDeserializer, "simpleReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<simpleReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "GenerateSimpleDataReturn");
		eSoapDeserializer.getParser().nextToken();
		return generateSimpleDataReturn;
	}

	public static MultiParamMethodReturn parseMultiParamMethodReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseMultiParamMethodReturn()");

		MultiParamMethodReturn multiParamMethodReturn = new MultiParamMethodReturn();
		Boolean isintReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("intReturn") && isintReturnUnReaded){

 				multiParamMethodReturn.setIntReturn(eSoapDeserializer.parseIntegerElem("intReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<intReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "MultiParamMethodReturn");
		eSoapDeserializer.getParser().nextToken();
		return multiParamMethodReturn;
	}

	public static StringInOutReturn parseStringInOutReturn(EfficientSoapDeserializer<?> eSoapDeserializer, String tag) throws XmlPullParserException, IOException, EfficientSoapFaultException
	{
		Log.d(TAG, "parseStringInOutReturn()");

		StringInOutReturn stringInOutReturn = new StringInOutReturn();
		Boolean isstringReturnUnReaded = true;

		eSoapDeserializer.getParser().require(XmlPullParser.START_TAG, null, tag);
		eSoapDeserializer.getParser().nextToken();

		eSoapDeserializer.skipWhitespace();
		while (eSoapDeserializer.getParser().getEventType() == XmlPullParser.START_TAG) {
		if (eSoapDeserializer.getParser().getName().equals("stringReturn") && isstringReturnUnReaded){

 				stringInOutReturn.setStringReturn(eSoapDeserializer.parseStringElem("stringReturn"));
				eSoapDeserializer.skipWhitespace();
			}

			else
				throw new XmlPullParserException("The Tag <"+eSoapDeserializer.getParser().getName()
							+"> was not expected "
							+"The Expecting Tag must be one Kind of this: "+
							"<stringReturn>, "
							+"or is already processed"
				);
		eSoapDeserializer.skipWhitespace();

		}
		eSoapDeserializer.getParser().require(XmlPullParser.END_TAG, null, "StringInOutReturn");
		eSoapDeserializer.getParser().nextToken();
		return stringInOutReturn;
	}

}
